import requests
import json

# 请求头
header = {
    'Content-Type': 'application/json'
}


# 发送信息到钉钉群
def dd_msg(url, msg):
    # 发送消息内容
    msg = {"msgtype": "text", "text": {"content": msg}}

    # 将字典转换成json字符串
    json_msg = json.dumps(msg)
    # 发送告警信息
    requests.post(url=url, headers=header, data=json_msg)


# 发送消息到飞书群
def fs_msg(url, msg):
    # 发送消息内容
    msg = {"msg_type": "text", "content": {"text": msg}}

    # 将字典转换成json字符串
    json_msg = json.dumps(msg)
    # 发送告警信息
    requests.post(url=url, headers=header, data=json_msg)


if __name__ == '__main__':
    dd_url = 'https://oapi.dingtalk.com/robot/send?access_token=7aed8df41413753f81811932131a4d1ca20a122a68a176fe72738b14f1d2c7c8'
    dd_msg(dd_url, "告警：数据过多")

    fs_url = "https://open.feishu.cn/open-apis/bot/v2/hook/6ce90ca2-47b3-4e80-98e4-e830d98bb0d9"

    fs_msg(fs_url, "告警：数据过多")
